import component from "element-plus/es/components/tree-select/src/tree-select-option.mjs";
import { createRouter, createWebHashHistory } from "vue-router";

let redirect = "";
if(import.meta.env.VITE_BUILD_CONFIG_SERVER) { // TCP转发
  redirect = "/home/dataForward";
} else if (import.meta.env.VITE_BUILD_CONFIG_PARSE) { // ZX解算配置中心
  redirect = "/home/rtcm";
} else if (import.meta.env.VITE_BUILD_CONFIG_NTRIP) { // Ntrip配置中心
  redirect = "/home/StationManage";
} else if (import.meta.env.VITE_BUILD_CONFIG_COLLECT) { // 数据采集
  redirect = "/home/DataCollect";
}


const routes = [
  {
    path: "/",
    redirect: redirect,
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/Login.vue"),
  },
  {
    path: "/home",
    name: "Home",
    component: () => import("@/views/Layout.vue"),
    children: [
      {
        path: "dataForward", // TCP转发
        name: "DataForward",
        component: () => import("@/views/home/DataForward1.vue"),
      },
      {
        path: "rtcm",
        name: "dataForward",
        component: () => import("@/views/home/Rtcm.vue"), // ZX解算配置中心
      },
      {
        path: "help",
        name: "HelpDoc",
        component: () => import("@/views/home/HelpDoc.vue"),
      },
      {
        path: "StationManage",
        name: "StationManage",
        component: () => import("@/views/home/StationManage.vue"),
      },
      {
        path: "UserManage",
        name: "UserManage",
        component: () => import("@/views/home/UserManage.vue"),
      },
      {
        path: "DataCollect", // 数据采集
        name: "DataCollect",
        component: () => import("@/views/data/DataCollect.vue"),
      },
      {
        path: "CollectTemp", // 数据采集
        name: "CollectTemp",
        component: () => import("@/views/home/CollectTemp.vue"),
      },
      {
        path: "OtaCenter", // 数据采集
        name: "OtaCenter",
        component: () => import("@/views/home/OtaCenter.vue"),
      },
      {
        path: "DataCollectView/:id/:groupId", // 采集器
        name: "DataCollectView",
        component: () => import("@/views/data/components/DataCollectView.vue"),
      },
      {
        path: "SolutionService", // 解算服务
        name: "SolutionService",
        component: () => import("@/views/home/SolutionService.vue"),
      }
    ],
  },
];

const router = createRouter({
  routes,
  history: createWebHashHistory(),
});

export default router;
